package com.zd.config;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author TSP
 * @Date 2021/8/22 17:26
 * @ClassName Result
 * @Description ：公共返回对象
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "Result", description = "公共返回对象")
public class Result {
    private Integer code;
    private String message;
    private Object obj;

    /**
     * 成功，带信息
     *
     * @param message
     * @return
     */
    public static Result success(String message) {
        return new Result(200, message, null);
    }


    /**
     * 成功，带信息和对象
     *
     * @param message
     * @return
     */
    public static Result success(String message, Object obj) {
        return new Result(200, message, obj);
    }

    /**
     * 失败，带信息
     *
     * @param message
     * @return
     */
    public static Result error(String message) {
        return new Result(500, message, null);
    }


    /**
     * 失败，带信息和对象
     *
     * @param message
     * @return
     */
    public static Result error(String message, Object obj) {
        return new Result(500, message, obj);
    }
}
